package com.wind.bdg.middlewarelearndemo.util;

import java.io.File;
import java.util.List;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class DownloadContent {
	public static void main(String[] args) throws Exception {
		App app = new App();
		List list = App.getUrl("http://10.202.32.15/medicine/medicine/webNewsList.do?id=505798913");
		
		for(int i=0;i<list.size();i++) {
			String url = (String) list.get(i);
			String id = ((String) list.get(i)).replaceAll(".*?id=","");
			mkTxt(id);
			Document document = Jsoup.connect(url).get();
	    	String doc = document.toString();
			Url2Text url2Text = new Url2Text();
			String idName = "C:\\Users\\Administrator\\Desktop\\网页内容\\"+id+".txt";
			url2Text.write2txt(doc, idName);
		}
		
		
	}
	public static void mkTxt(String id) throws Exception {
		
		String fileName =id+".txt";
        File testFile = new File("C:\\Users\\Administrator\\Desktop\\网页内容\\" + fileName);
        if (!testFile.exists()) {
            testFile.createNewFile();// 能创建多级目录
//            System.out.println("ok");
        }
}
}
